import Vue from 'vue';
import * as Sentry from '@sentry/browser';
import * as Integrations from '@sentry/integrations';

Sentry.init({
  // todo 更换为绿通项目地址
  // dsn: 'https://e34b81498b264854b512c7241d071831@sentry.lejian.com/2',
  integrations: [new Integrations.Vue({ Vue, attachProps: true })],
  environment: `h5-${process.env.BUILD_ENV || process.env.NODE_ENV}`,
  enabled: process.env.NODE_ENV === 'production',
});

Object.defineProperties(Vue.prototype, {
  $log: {
    get: () => Sentry.captureException.bind(null),
  },
});

const plugin = (cxt, inject) => {
  cxt.$log = Sentry.captureException.bind(null);
};

export default plugin;
